import http from "@/http/index";
import qs from "qs";
// qs.stringify
//注册
export const loginApi = (phone: string): RES<number> =>
  http.post("/sendSMS", { phone });
//登录 /phoneRegin
export const phoneReginApi = (params: ILoginParams): Promise<IPhoneLogin> =>
  http.post("/phoneRegin", qs.stringify(params));

//获取用户信息 /shop/userProfiles
export const userProfilesApi = (): RES<any> => http.get("/shop/userProfiles");
//手机绑定微信 /wechatUsers/binding
export const weChatBindingApi = (params: IPCLogInParams): Promise<IWxLogin> =>
  http.post("/wechatUsers/binding", qs.stringify(params));
//微信登录 /wechatUsers/PCLogin
export const weChatUsersApi = (code: string): Promise<IWxLogin> =>
  http.post("/wechatUsers/PCLogin", qs.stringify({ code }));

//详情页数据 /products/{id}
export const productsApi = (id: number): RES<IProducts> =>
  http.get("/products/" + id);
///shop/carts/add 加入到购物车
export const cartsAddApi = (params: ICarts): Promise<any> =>
  http.post("/shop/carts/add", qs.stringify(params));
interface ILoginParams {
  phone: string;
  verifyCode: string;
}
interface IPCLogInParams extends ILoginParams {
  uuid: string;
}
interface ICarts {
  productId: string;
  total: number | number;
  immediate?: string | number; //immediate为1，表示立即购买
  modified?: string | number; //modified为1，可直接修改购物车中的商品数量
}
